package com.longrise.co.ui.carfiles.adapter;

import android.content.Context;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.longrise.co.R;
import com.longrise.co.ui.carfiles.model.UploadPhotoBean;
import com.longrise.co.utils.Constants;
import com.ly.common.commonutils.ImageLoaderUtils;
import com.ly.common.commonutils.StringUtils;

import java.util.List;


/**
 * Created by admin on 2017/2/4.
 */

public class UploadPhotoAdapter extends BaseMultiItemQuickAdapter<UploadPhotoBean> {

    private Context mContext;

    public UploadPhotoAdapter(Context context, List<UploadPhotoBean> listData) {
        super(listData);
        mContext = context;
        addItemType(Constants.UPLOAD_TYPE_ONE, R.layout.item_upload_image);
        addItemType(Constants.UPLOAD_TYPE_TWO, R.layout.item_upload_add);

    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, UploadPhotoBean o) {
        String value = o.getValue();
        switch (baseViewHolder.getItemViewType()) {
            case Constants.UPLOAD_TYPE_ONE :
                ImageView iv = baseViewHolder.getView(R.id.photo);
                if(!StringUtils.isEmpty(value)) {
                    ImageLoaderUtils.display(mContext, iv, value.trim());
                }
                break;
            case Constants.UPLOAD_TYPE_TWO :
                baseViewHolder.setText(R.id.upload_count, "还能上传" + value + "张");
                break;
        }
    }

}
